package com.lbn.jfqsc.app.login;

import com.google.gson.Gson;
import com.lbn.baseframe.mvp.BasePresenter;
import com.lbn.baseframe.net.Retrofit2Factory;
import com.lbn.baseframe.net.business.RxSubscribe;
import com.lbn.baseframe.utils.L;
import com.lbn.jfqsc.business.bean.User;
import com.lbn.jfqsc.net.Host;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 李炳南
 * @date 2017/2/28
 */
public class LoginPresenter extends BasePresenter<ILoaginView> {




    public void login(String userName,String password){

        Map<String,String>map = new HashMap<>();
        map.put("phone",userName);
        map.put("password",password);

        subscribeNetwork(Host.getApi().token(map), new RxSubscribe<User>() {
            @Override
            public void next(User user) {
                L.e("UserJson:"+new Gson().toJson(user));
                getView().onSucceed(user);
            }

            @Override
            public void error(Throwable e) {
                getView().onError(e.getMessage());
            }
        });
    }


}
